const http = require('utils/http.js')
App({
  onLaunch: function() {
    // 登录
    wx.login({
      success: res => {
        http.get('/api/user/login', res).then(res => {
          if (res.code == 200) {
            this.globalData.customerName = res.result.customerName
            wx.setStorageSync("token", res.result.token);
          }
        })
      }
    })

    // 获取系统状态栏信息
    wx.getSystemInfo({
      success: e => {
        this.globalData.StatusBar = e.statusBarHeight;
        let capsule = wx.getMenuButtonBoundingClientRect();
        if (capsule) {
         	this.globalData.Custom = capsule;
        	this.globalData.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight;
        } else {
        	this.globalData.CustomBar = e.statusBarHeight + 50;
        }
      }
    })
  },
  globalData: {
    userInfo: wx.getStorageSync("userInfo")
    //测试使用
    // userInfo: Object.assign(wx.getStorageSync("userInfo"), {payOpenid: 'oj-DM5jBA-EPgWB5FUFxz01ZZ0bQ'})
  }
})
